#!/bin/bash
# File: /usr/lib/nagios/plugins/check_app

if [ -z "$1" ]
then
  echo "No web-server given."
  exit 3
fi

state=`wget -q $1 && echo "yes" || echo "no"`

if [ "$state" == "yes" ]
then
  echo "state active"
  exit 0
fi

if [ "$state" == "no" ]
then
  echo "Error! (state inactive) input: $1"
  mail -s "Alert" root@localhost < /dev/null
  exit 2
fi

exit 3